/**
 * 1. Hypertext Transfer Protocol  超文本传输协议
 * 2. Uniform Resource Locator 统一资源定位符
 */

const http = require("http");
const { URL } = require("url");

// 创建一个 服务
const server = http.createServer((request, response) => {
  // console.log(request.url);
  const url = new URL(request.url, "http://127.0.0.1:9000");
  console.log("url", url);
  if (url.pathname == "/login") {
    response.end("login");
  } else if (url.pathname == "/regist") {
    response.end("regist");
  } else {
    response.end("server");
  }
});

// 监听该服务   该回调会在每次响应http的时候调用
server.listen(9000, () => {
  console.log("服务启动了");
});
